﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PccCommonForC;
using bs_ShowRoom;
namespace ShowRoom.admin
{
    public partial class IntroManager : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetIntro();
            }
        }
        private void GetIntro()
        {
            DataTable dt = GetMenuDetail();
            if (dt.Rows.Count > 0)
            {
                tctchitiet.Value = dt.Rows[0]["content"].ToString().Trim();
            }
        }
        private DataTable GetMenuDetail()
        {
            bs_info mybs = new bs_info(ConfigurationManager.ConnectionStrings["ShowRoomConnectionString"].ToString());
            PccMsg myMsg = new PccMsg();

            DataSet ds = mybs.DoReturnDataSet("GETINTRODUCTION", myMsg.GetXmlStr, "");
            DataTable dt = new DataTable();
            if (ds.Tables.Count > 0)
                dt = ds.Tables[0];
            return dt;
        }
        private string fnInsUpdIntro(string id_intro, string content,string upd_id, string myType)
        {
            PccMsg myMsg = new PccMsg();
            myMsg.CreateFirstNode("id_intro", id_intro);
            myMsg.CreateFirstNode("content", content);
            myMsg.CreateFirstNode("upd_id",upd_id);
            myMsg.CreateFirstNode("Type", myType);

            bs_info mybs =new bs_info(ConfigurationManager.ConnectionStrings["ShowRoomConnectionString"].ToString());

            string strXML = myMsg.GetXmlStr;
            string strReturn = mybs.DoReturnStr("INSUPDINTRODUCTION", strXML, "");
            return strReturn;
            //*****************************************************************************
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string upd_id = "1";
            string myStrReturn = fnInsUpdIntro("0", tctchitiet.Value,upd_id, "0");


            if (myStrReturn != "")
            {
                ScriptFunction.ShowMsgTranOpennerUrl_ScriptManager("cập nhật thành công ", Page, "IntroManager.aspx");

                // Response.Write("<script>alert('cập nhật thành công !')</script");
            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Write("<script>window.close();</script>");
        }
    }
}